<template>
  <div id="body">
    <van-row>
      <van-col span="24" id="hh">
        <van-nav-bar
          title="我的下单"
          left-text="返回"
          left-arrow
          @click-left="backOff()"
        />
      </van-col>
    </van-row>
    <div class="kp" v-for="item in orderList" :key="item">
      <div class="clearfix">
        <div class="head">
          <img :src="urAvatar" alt="" />
          <p>{{item.ofTitle}}</p>
        </div>
        <div class="right">
          <div class="ztai">
            <p v-show="item.ofState == 1">未接单</p>
            <p v-show="item.ofState == 2">进行中</p>
            <p v-show="item.ofState == 3">已完成</p>
          </div>
        </div>
      </div>
      <div class="body" @click="xq(item.ofId, haveOrder)">
        <p class="ppp">{{item.ofDescribe.substring(0,(item.ofDescribe).length/2)}}</p>
      </div>
      <div class="body">
          <p class="end">{{item.ofLabel}}</p>
      </div>
      <div class="zf">
          <div class="qd">
              <div class="le">
                  <p>￥{{item.ofPrice}}</p>
              </div>
              <div class="qx">
                  <p v-show="item.ofState == 1">未接单</p>
                  <p v-show="item.ofState == 2" @click="qx(item.ofId)">进行中</p>
                  <p v-show="item.ofState == 3">已完成</p>
              </div>
          </div>
      </div>
    </div>
    
  </div>
</template>

<script>
import { Toast } from "vant";
import api from "@/api/order";
export default {
  created() {
    api.lookAllById(this.urId).then((res) => {
      console.log(res);
      this.orderList = res.data.data.list;
    });
  },
  methods: {
    qx(ofId) {
      var order = {
        ofId: ofId,
        ofState: 1,
      };
      api.updataOrder(order).then((res) => {
        this.getlist();
        this.$dialog({
          message: res.data.message,
        });
      });
    },
    backOff(){
      this.$router.go(-1)
    },
    // onClickLeft() {
    //   Toast("返回");
    // },
    xq(ofId, haveOrder) {
      var _this = this;
      this.$router.push({
        path: "/XQ",
        query: {
          ofId: ofId,
        },
      });
    },
    findOrderByofId() {
      api.info(this.ddn).then((res) => {
        this.order.ofCreateTime = res.data.data.ddOrderForm.ofCreateTime
        this.order.ofDescribe = res.data.data.ddOrderForm.ofDescribe
        this.order.ofId = res.data.data.ddOrderForm.ofId
        this.order.ofLabel = res.data.data.ddOrderForm.ofLabel
        this.order.ofPrice = res.data.data.ddOrderForm.ofPrice
        this.order.ofRedPacket = res.data.data.ddOrderForm.ofRedPacket
        this.order.ofState = res.data.data.ddOrderForm.ofState
        this.order.ofTitle = res.data.data.ddOrderForm.ofTitle
        this.order.ofUrId = res.data.data.ddOrderForm.ofUrId
        this.orderList = []
        this.orderList[0] = this.order
      });
    },
  },
  data() {
    return {
      ddn: "",
      urId: this.$route.query.urId,
      orderList: [],
      urAvatar: localStorage.getItem("userAvatar"),
      order: {
        ofCreateTime: "2021/10/31/ 22:26",
        ofDescribe: "123",
        ofId: "d624600920d1082d1e6b4a0d7e739ecc",
        ofLabel: "Android",
        ofPrice: 132,
        ofRedPacket: "31231231231",
        ofState: "1",
        ofTitle: "123",
        ofUrId: 7,
      },
      //   order: {
      //     ofCreateTime: "2021年10月31天 15时16分",
      //     ofDescribe: "测试",
      //     ofEndTime: "2021年11月07天 15时16分",
      //     ofId: "cbd11155c5f94410a40aa1946010deaaf",
      //     ofLabel: "java",
      //     ofPrice: 220,
      //     ofTitle: "测试",
      //     ofUrId: 9,
      //   },
    };
  },
};
</script>

<style scoped>
* {
  margin: 0;
  padding: 0;
}
.clearfix:after {
  content: "";
  display: block;
  height: 0;
  clear: both;
  visibility: hidden;
}
.clearfix {
  *zoom: 1;
}
.kp {
  padding: 20px;
  width: 88%;
  height: 130px;
  margin: 0 auto;
  background-color: #fefefe;
  border-radius: 30px;
  box-shadow: 2px 2px 7px 0px #d1d1d1;
  margin-bottom: 10px;
}
.kp .head {
  float: left;
}
.ppp {
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}
.kp .head img {
  width: 30px;
  height: 30px;
  vertical-align: middle;
  border-radius: 50%;
}
.kp .head p {
  display: inline-block;
  /* line-height: 30px; */
  margin-left: 10px;
  color: #232223;
  font-weight: 900;
}
.kp .right {
  float: right;
}
.kp .right .ztai {
  width: 67px;
  height: 32px;
  background-color: #f1fbfa;
}
.kp .right .ztai p {
  line-height: 32px;
  color: #5baa94;
  margin-left: 10px;
  font-size: 15px;
  font-weight: 800;
}
.kp .body {
  margin-top: 13px;
}
.kp .body p {
  color: #111111;
  margin-left: 20px;
  line-height: 30px;
}
.kp .body .end {
  color: #7b83ad;
  font-size: 14px;
  line-height: 3px;
}
.kp .zf .qd {
  float: right;
  width: 150px;
  height: 40px;
  /* background-color: pink; */
}
.kp .zf .qd .le {
  float: left;
  width: 76px;
  height: 40px;
  background-color: #fdf5f4;
  border-radius: 10px;
  line-height: 40px;
  color: #ba898e;
  font-size: 12px;
}
.kp .zf .qd .le p {
  margin-left: 6px;
}
.kp .zf .qd .qx {
  width: 50px;
  height: 38px;
  line-height: 40px;
  float: left;
  border: 1px solid #000;
  margin-left: 15px;
  border-radius: 10px 0 10px 0;
}
.kp .zf .qd .qx p {
  margin-left: 16%;
  font-size: 10px;
}
#body #tou {
  padding-bottom: 10px;
  padding-left: 10px;
  color: #3d3d3d;
}
#body #tou #hh {
  display: inline;
}
#body #tou #jz {
  margin-top: -19px;
  text-align: center;
}
#body {
  padding: 20px;
  background: #f9f9f9;
}
/deep/ .van-nav-bar__content {
  background-color: #f9f9f9;
  border-bottom: #f9f9f9;
}
</style>